<%--
  Created by IntelliJ IDEA.
  User: aaa
  Date: 2024/6/24
  Time: 4:29
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <title>Title</title>
</head>
<style>
    #content {
        border: black solid 5px;
        width: 1100px;
        height: 800px;
        margin-top: -280px;
        margin-left: 230px;
        color: grey;
        font-size: 50px;
    }

    .firstHang {
        text-align: center;
        border: none;
    }

</style>
<body>
<div id="content">
    <table border="1" cellspacing="0" align="center" class="con-b" width="100%">

        <tr>
            <td colspan="8" class="firstHang">
                <%--学生就搜索老师--%>
                <c:if test="${session_newUser.getUserIdentify()==0 }">
                    <form action="StudentServlet" method="get">
                        <input type="text" name="searchText">&nbsp;&nbsp;
                        <input type="hidden" name="action" value="searchTeacher">
                        <input type="submit" value="查询">
                    </form>
                </c:if>
                    <%--是老师就搜索学生--%>
                <c:if test="${session_newUser.getUserIdentify()==1}">
                    <form action="TeacherServlet" method="get">
                        <input type="text" name="searchText">&nbsp;&nbsp;
                        <input type="hidden" name="action" value="searchMyStudent">
                        <input type="submit" value="查询">
                    </form>
                </c:if>
                    <%--是管理员就搜索全部--%>
                    <c:if test="${session_newUser.getUserIdentify()==2}">
                        <form action="ManagerServlet" method="get">
                            <input type="text" name="searchText">&nbsp;&nbsp;
                            <input type="hidden" name="action" value="search">
                            <input type="submit" value="查询">
                        </form>
                    </c:if>

            </td>
        </tr>
        <tr class="row" style="color: black;font-size: 25px">
            <td class="lf">账户</td>
            <td class="lf">姓名</td>
            <td class="lf">性别</td>
            <%--当登录用户不为0即不为学生时才显示这个信息--%>
            <c:if test="${session_newUser.getUserIdentify()!=0 }">
                <td class="lf">出生日期</td>
                <td class="lf">身份证</td>
                <td class="lf">角色</td>
            </c:if>
            <td class="lf">其他名称</td>
            <td colspan="3">操作</td>
        </tr>

        <%--具体内容--%>
        <tbody>
        <c:forEach items="${userList}" var="user">
            <tr class="row" style="color: black;font-size: 25px">
                <td class="lf">${user.getUserAccount()}</td>
                <td class="lf">${user.getUserName()}</td>
                <td class="lf">${user.getUserSex()}</td>
                    <%--不为0即不是学生登录才显示这些信息--%>
                <c:if test="${session_newUser.getUserIdentify()!=0 }">
                    <td class="lf">${user.getUserBirthday() }</td>
                    <td class="lf">${user.getUserIdCard()}</td>
                    <td class="lf">
                        <c:if test="${user.getUserIdentify()==0 }">
                            学生
                        </c:if>
                        <c:if test="${user.getUserIdentify()==1 }">
                            老师
                        </c:if>
                    </td>
                </c:if>
                <td class="lf">${user.getUserOtherName()}</td>
                   <%--等于1时,老师可以删除--%>
                <c:if test="${session_newUser.getUserIdentify()==1 }">
                    <td><input type="button" value="删除" onclick="deleteThisPersonByTeacher('${user.getUserAccount()}')"></td>
                </c:if>
                <%--等于2时，管理员可以删除--%>
                <c:if test="${session_newUser.getUserIdentify()==2 }">
                    <td><input type="button" value="删除" onclick="delThisPerson('${user.getUserAccount()}','${user.getUserIdentify()}')"></td>
                </c:if>


                <c:if test="${session_newUser.getUserIdentify()!=0 }">
                    <td>
                            <%--登录者为老师,查看学生任务的详细信息--%>
                        <c:if test="${session_newUser.getUserIdentify()==1 }">
                            <input type="button" value="查案任务详情" onclick="detailTask('${user.getUserAccount()}')">
                        </c:if>
                    </td>
                </c:if>

                <%--<c:if test="${session_newUser.getUserIdentify()==0 }">
                    学生操作
                </c:if>--%>
                <c:if test="${session_newUser.getUserIdentify()==0 }">

                    <td><input type="button" value="添加" onclick="addTeacher('${user.getUserAccount()}')"></td>
                </c:if>
            </tr>

        </c:forEach>
        </tbody>

        <tr></tr>
    </table>
</div>
</body>
<script>
    function delThisPerson(userAccount,userIdentify){

        window.location.href ="ManagerServlet?action=delThisPerson&userAccount="+userAccount+"&userIdentify="+userIdentify;
    }
function addTeacher(teacherAccount){
    window.location.href ="StudentServlet?action=addTeacher&teacherAccount="+teacherAccount;
}

    function detailTask(studentAccount) {
        window.location.href = "TeacherServlet?action=goStudentTaskDetail&studentAccount=" + studentAccount;
    }

    function deleteThisPersonByTeacher(studentAccount) {
        window.location.href ="TeacherServlet?action=deleteThisPersonByTeacher&studentAccount="+studentAccount;
    }




</script>
</html>


